package ru.ifmo.trafficspy.provider;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import ru.ifmo.trafficspy.common.Item;
import ru.ifmo.trafficspy.common.Packet;
import ru.ifmo.trafficspy.common.Interval;

public class TestProvider extends Provider {

	public TestProvider() {
		super("Two states Markov chain");
	}

	private static Random rand = new Random();
	
	private static int random(int l, int r) {
		return l + rand.nextInt(r - l + 1);
	}
	
	@Override
	public List<Item> getTraffic() {
		ArrayList<Item> res = new ArrayList<Item>();
		Random r = new Random();
		int state = 0;
		for (int i = 0; i < 21; i++) {
			if (state == 0) {
				if (r.nextDouble() > 0.25) {
					res.add(new Packet(10 + random(-1, 1)));
				} else {
					res.add(new Packet(20 + random(-1, 1)));
				}
				state = 1;
			} else {
				res.add(new Interval(100));
				state = 0;
			}
		}
		return res;
	}

}
